<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let rows = prompt("请输入行数");
        rows = parseInt(rows);
        let pyramid = "";
        for (let i = 1; i <= rows; i++) {

            for (let j = 1; j <= rows - i; j++) {
                pyramid += " ";
            }

            for (let k = 1; k <= 2 * i - 1; k++) {
                pyramid += "金";
            }
            pyramid += "\n";
        }
        alert(pyramid);
    </script>
</body>
</html>

